//
//  BKPhonePaySkipVC.m
//  bestkeep
//
//  Created by 李明 on 2017/1/18.
//  Copyright © 2017年 utouu. All rights reserved.
//

#import "BKPhonePaySkipVC.h"
#import "BKMainCommon.h"
#import "BKIntegralViewController.h"
#define BKPhonePaySkipVCSelectColor RGB(0, 186, 156)

@interface BKPhonePaySkipVC ()

@property (nonatomic, strong) UIImageView *headerImageView;
@property (nonatomic, strong) UILabel *subLabel;
@property (nonatomic, strong) UILabel *integralLabel;
@property (nonatomic, strong) UIImageView *integralImageView;
@property (nonatomic, strong) UIButton *backFirstPage;
@property (nonatomic, strong) UIButton *backIntegralPage;

@end

@implementation BKPhonePaySkipVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItems = nil;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    [self.navigationItem setHidesBackButton:YES];
    self.view.backgroundColor = [UIColor whiteColor];
    [self initView];
    
    // Do any additional setup after loading the view.
}

- (void)initView {
    
    self.headerImageView = [[UIImageView alloc] init];
    [self.view addSubview:self.headerImageView];
    
    self.subLabel = [[UILabel alloc] init];
    [self.view addSubview:self.subLabel];
    
    self.subLabel.textColor = RGB(102, 102, 102);
    self.subLabel.font = [UIFont systemFontOfSize:18];
    [self.subLabel setTextAlignment:NSTextAlignmentCenter];
    
    if (self.isPaySuccess) { //成功；
        
        [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(60.5f);
            make.centerX.mas_equalTo(self.view.mas_centerX);
            make.width.mas_equalTo(71);
            make.height.mas_equalTo(71);
        }];
        
        [self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.headerImageView.mas_bottom).offset(22);
            make.centerX.mas_equalTo(self.view.mas_centerX);
            make.height.mas_equalTo(18);
            make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.5);
        }];
        
        self.title = BKMainLocalizedString(@"BKPhonePaySkipSuccessTitle");
        self.headerImageView.image = [UIImage imageNamed:@"BKPhone_Ylogo"];
        self.subLabel.text = BKMainLocalizedString(@"BKPhonePaySkipSuccessTitle");
        self.integralLabel = [[UILabel alloc] init];
        self.integralLabel.textColor = RGB(217, 152, 13);
        self.integralLabel.text = [NSString stringWithFormat:@"恭喜您，充值成功后将获得%@积分",self.orderAlipayInfor.integralAmount];
        self.integralLabel.font = [UIFont systemFontOfSize:14];
        [self.view addSubview:self.integralLabel];
        [self.integralLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.subLabel.mas_bottom).offset(44.5f);
            make.centerX.mas_equalTo(self.view.mas_centerX).offset(9);
            
        }];
        self.integralImageView = [[UIImageView alloc] init];
        [self.view addSubview:self.integralImageView];
        self.integralImageView.image = [UIImage imageNamed:@"BKPhone_JFicon"];
        [self.integralImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(18);
            make.height.mas_equalTo(20);
            make.right.mas_equalTo(self.integralLabel.mas_left).offset(-5);
            make.centerY.mas_equalTo(self.integralLabel.mas_centerY);
        }];
        self.backFirstPage = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.backFirstPage setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.backFirstPage.backgroundColor = BKPhonePaySkipVCSelectColor;
        [self.backFirstPage setTitle:@"返回首页" forState:UIControlStateNormal];
        self.backFirstPage.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.backFirstPage addTarget:self action:@selector(backFirstPageAction) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:self.backFirstPage];
        [self.backFirstPage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.subLabel.mas_bottom).offset(117);
            make.left.mas_equalTo(self.view.mas_left).offset(ApplicationBackGauge);
            make.height.mas_equalTo(45);
        }];
        
        self.backIntegralPage = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.backIntegralPage setTitle:@"积分商城" forState:UIControlStateNormal];
        [self.backIntegralPage setTitleColor:BKPhonePaySkipVCSelectColor forState:UIControlStateNormal];
        self.backIntegralPage.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.backIntegralPage addTarget:self action:@selector(backIntegralPageAction) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:self.backIntegralPage];
        [self.backIntegralPage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.subLabel.mas_bottom).offset(117);
            make.right.mas_equalTo(self.view.mas_right).offset(-ApplicationBackGauge);
            make.height.mas_equalTo(45);
            make.left.mas_equalTo(self.backFirstPage.mas_right).offset(15);
            make.width.mas_equalTo(self.backFirstPage.mas_width);
        }];
        self.backFirstPage.layer.borderColor = BKPhonePaySkipVCSelectColor.CGColor;
        self.backFirstPage.layer.borderWidth = 1.0f;
        self.backFirstPage.layer.cornerRadius = 3;
        self.backFirstPage.layer.masksToBounds = YES;
        
        self.backIntegralPage.layer.borderColor = BKPhonePaySkipVCSelectColor.CGColor;
        self.backIntegralPage.layer.borderWidth = 1.0f;
        self.backIntegralPage.layer.cornerRadius = 3;
        self.backIntegralPage.layer.masksToBounds = YES;
        
    }else {
        
        [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(60.0f);
            make.centerX.mas_equalTo(self.view.mas_centerX);
            make.width.mas_equalTo(72);
            make.height.mas_equalTo(72);
        }];
        
        [self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.headerImageView.mas_bottom).offset(23);
            make.centerX.mas_equalTo(self.view.mas_centerX);
            make.height.mas_equalTo(18);
            make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.5);
        }];
        
        self.title = BKMainLocalizedString(@"BKPhonePaySkipFailedTitle");
        self.headerImageView.image = [UIImage imageNamed:@"BKPhone_Clogo_"];
        self.subLabel.text = BKMainLocalizedString(@"BKPhonePaySkipFailedTitle");
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"返回" forState:UIControlStateNormal];
        [button setTitleColor:BKPhonePaySkipVCSelectColor forState:UIControlStateNormal];
        [button addTarget:self action:@selector(backPage) forControlEvents:UIControlEventTouchUpInside];
        button.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.view addSubview:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(45);
            make.top.mas_equalTo(self.subLabel.mas_bottom).offset(112);
            make.centerX.mas_equalTo(self.view.mas_centerX);
            make.width.mas_equalTo(self.view.mas_width).multipliedBy(0.45f);
            
        }];
        button.layer.borderColor = BKPhonePaySkipVCSelectColor.CGColor;
        button.layer.borderWidth = 1.0f;
        button.layer.cornerRadius = 3;
        button.layer.masksToBounds = YES;
        
    }
}

- (void)backPage {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)backIntegralPageAction {
    
    BKIntegralViewController *signFirstVC = [[BKIntegralViewController alloc] init];
    [self.navigationController pushViewController:signFirstVC animated:YES];
}
- (void)backFirstPageAction {
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
